﻿import com.dinmax.isolution.*

class AppThemeButtonGUI
extends MovieClip {
	
	//movies de dibujo
	
	private var listener:ThemesBarGUI;
	private var _enabled:Boolean;
	private var themeID:String;
	
	function AppThemeButtonGUI(){
		//trace("new AppThemeButtonGUI");
		return;
	}
	
	function onLoad():Void {
		this.listener = ThemesBarGUI(this._parent);
		this.listener.registerChild(this);
		return;
	}
	
	public function onPress():Void {
		this.setEnabled(!this._enabled);
		return;
	}
	
	public function getEnabled():Boolean {
		return this._enabled;
	}
	
	public function setEnabled(b:Boolean):Void {
		this._enabled = b;
		
		if(this._enabled) {
			this.listener.onChange(this, "enabled");
			this.onEnterFrame=function(){
				if(this._alpha <= 45){
					//delete this.onEnterFrame; 
					this.onEnterFrame = function(){
						if(this._alpha >= 100){
							this._alpha = 100;
							delete this.onEnterFrame;
						} else {
							this._alpha += (105 - this._alpha)/70; 
						}
					}
				} else {
					this._alpha -= (this._alpha - 40)/2.5;
				}
				return;
			}
		} else {
			this.onEnterFrame=function(){
				if(this._alpha >= 100) {
					this._alpha = 100;
					delete this.onEnterFrame;
					this.listener.onChange(this, "enabled");
				} else {
					this._alpha += (105 - this._alpha)/3; 
				}
				return;
			};
		}
		return;
	};
	
	public function getThemeID():String{
		return this.themeID;
	}
	public function setThemeID(newThemeID:String):Void{
		this.themeID = newThemeID;
		return;
	}
	
}